home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / setEditorPanel.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  35.0 KB  |  1,098 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  April 24, 1997
  22. //  Author:         db
  23. //
  24. //  Description:
  25. //      This script creates a panel which has the set editor within it.
  26. //
  27. //  Input Arguments:
  28. //      None.
  29. //
  30. //  Return Value:
  31. //      None.
  32. //
  33.  
  34. source setEdBookmarkEditor.mel;
  35.  
  36. //string $setEd = "setEditor1SetEd";
  37.  
  38. global proc
  39. setEditorStateCallback(string $setEd)
  40. //
  41. //    SYNOPSIS
  42. //        Keeps the buttons on the toolbar in sync with
  43. //        the actual settings of the set editor - called
  44. //        when the trigger for the set editor, $setEd,
  45. //        is fired.
  46. {
  47.     setParent $setEd;
  48.  
  49.     //    Construct unique names for the buttons
  50.     //    for this instance of the editor
  51.  
  52.     string $setEdToolBarForm    = ($setEd + "toolbarForm");
  53.     string $editModeBtn            = ($setEd + "editModeBtn");
  54.     string $selectModeBtn        = ($setEd + "selectModeBtn");
  55.     string $contentsModeBtn        = ($setEd + "contentsModeBtn");
  56.     string $paintModeBtn        = ($setEd + "paintModeBtn");
  57.     string $scrollBtn            = ($setEd + "scrollBtn");
  58.     string $expandAllBtn        = ($setEd + "expandAllBtn");
  59.     string $collapseAllBtn        = ($setEd + "collapseAllBtn");
  60.     string $addItemsBtn            = ($setEd + "addItemsBtn");
  61.     string $removeItemsBtn        = ($setEd + "removeItemsBtn");
  62.     string $listSetsBtn            = ($setEd + "listSetsBtn");
  63.     string $listPartitionsBtn    = ($setEd + "listPartitionsBtn");
  64.  
  65.     int $enableToolbar = !`setEditor -query -autoUpdate $setEd`;
  66.     rowLayout -edit -enable $enableToolbar $setEdToolBarForm;
  67.     if (!$enableToolbar)
  68.         return;
  69.  
  70.     string $operatingMode = `setEditor -query -mode $setEd`;
  71.     symbolCheckBox -edit
  72.         -value ($operatingMode == "editing")
  73.         $editModeBtn;
  74.     symbolCheckBox -edit
  75.         -value ($operatingMode == "selectNoExpand")
  76.         $selectModeBtn;
  77.     symbolCheckBox -edit
  78.         -value ($operatingMode == "selectExpand")
  79.         $contentsModeBtn;
  80.     symbolCheckBox -edit
  81.         -value ($operatingMode == "paint")
  82.         $paintModeBtn;
  83.  
  84.     button -e -enable ($operatingMode == "editing") $addItemsBtn;
  85.     button -e -enable ($operatingMode == "editing") $removeItemsBtn;
  86.  
  87.     symbolCheckBox -edit 
  88.         -value `setEditor -query -editSets $setEd`
  89.         $listSetsBtn;
  90.     symbolCheckBox -edit 
  91.         -value `setEditor -query -editPartitions $setEd`
  92.         $listPartitionsBtn;
  93.  
  94.     if ($operatingMode == "selectExpand" || $operatingMode == "selectNoExpand")
  95.     {
  96.         button -e -enable false $scrollBtn;
  97.         button -e -enable false $expandAllBtn;
  98.         button -e -enable false $collapseAllBtn;
  99.     }
  100.     else
  101.     {
  102.         int $enableScroll = `setEditor -query -groupComponents $setEd`;
  103.         button -e -enable $enableScroll $scrollBtn;
  104.         button -e -enable true $expandAllBtn;
  105.         button -e -enable true $collapseAllBtn;
  106.     }
  107. }
  108.  
  109. // *********************************************
  110. // The next bit are all menu creation procedures
  111. // *********************************************
  112.  
  113. global proc
  114. buildSetEdModeMenu (string $setEd, string $parentMenu)
  115. {
  116.     setParent -menu $parentMenu;
  117.  
  118.     // These should be unique enough names for the widgets for this
  119.     // instance of the set editor
  120.  
  121.     string $editingItem        = ($setEd + "editingItem");
  122.     string $selectNoExpandItem = ($setEd + "selectNoExpandItem");
  123.     string $selectExpandItem   = ($setEd + "selectExpandItem");
  124.     string $paintItem          = ($setEd + "paintItem");
  125.  
  126.     // Check to see if we have to build the menu items
  127.  
  128.     if (`menu -query -numberOfItems $parentMenu` == 0)
  129.     {
  130.         radioMenuItemCollection;
  131.         menuItem -label "Editing"
  132.             -radioButton true
  133.             -command ("setEditor -edit -mode editing " + $setEd)
  134.             $editingItem;
  135.         menuItem -label "Select"
  136.             -radioButton false
  137.             -command ("setEditor -edit -mode selectNoExpand " + $setEd)
  138.             $selectNoExpandItem;
  139.         menuItem -label "Select Contents"
  140.             -radioButton false
  141.             -command ("setEditor -edit -mode selectExpand " + $setEd)
  142.             $selectExpandItem;
  143.         menuItem -label "Paint Percentages"
  144.             -radioButton false
  145.             -command ("setEditor -edit -mode paint " + $setEd)
  146.             $paintItem;
  147.     }
  148.  
  149.     // Update radio button checks for operating mode
  150.  
  151.     string $operatingMode = `setEditor -query -mode $setEd`;
  152.     menuItem -edit
  153.         -radioButton ($operatingMode == "editing")
  154.         $editingItem;
  155.     menuItem -edit
  156.         -radioButton ($operatingMode == "selectNoExpand")
  157.         $selectNoExpandItem;
  158.     menuItem -edit
  159.         -radioButton ($operatingMode == "selectExpand")
  160.         $selectExpandItem;
  161.     menuItem -edit
  162.         -radioButton ($operatingMode == "paint")
  163.         $paintItem;
  164. }
  165.  
  166. //
  167. //  Procedure Name:
  168. //      setEditorAddChannelBoxToSet
  169. //
  170. //  Description:
  171. //        Adds the selected attributes in the channel box to the highlighted set.
  172. //
  173. //  Input Arguments:
  174. //      $setEd - the set editor to add the items to
  175. //
  176. //  Return Value:
  177. //      None.
  178. //
  179. global proc setEditorAddChannelBoxToSet( string $setEd ) 
  180. {
  181.     int $itemsAdded = false;
  182.     string $mainAttrs[]    = 
  183.         `channelBox -q -selectedMainAttributes mainChannelBox`;
  184.     string $mainNodes[]    = 
  185.         `channelBox -q -mainObjectList mainChannelBox`;
  186.     string $shapeAttrs[] = 
  187.         `channelBox -q -selectedShapeAttributes mainChannelBox`;
  188.     string $shapeNodes[] = 
  189.         `channelBox -q -shapeObjectList mainChannelBox`;
  190.     string $historyAttrs[] = 
  191.         `channelBox -q -selectedHistoryAttributes mainChannelBox`;
  192.     string $historyNodes[] = 
  193.         `channelBox -q -historyObjectList mainChannelBox`;
  194.  
  195.     // Check if there are attributes selected in the channel box.
  196.     // If there are, we'll add those to the set instead
  197.     //
  198.     if ( size( $mainAttrs ) > 0 ) {
  199.         for ( $node in $mainNodes ) {
  200.             for ( $attr in $mainAttrs ) {
  201.                 setEditor -edit -addToSet -itemToAdd ( $node + "." + $attr ) 
  202.                     $setEd;
  203.             }
  204.         }
  205.         $itemsAdded = true;
  206.     }
  207.     if ( size( $shapeAttrs ) > 0 ) {
  208.         for ( $node in $shapeNodes ) {
  209.             for ( $attr in $shapeAttrs ) {
  210.                 setEditor -edit -addToSet -itemToAdd ( $node + "." + $attr ) 
  211.                     $setEd;
  212.             }
  213.         }
  214.         $itemsAdded = true;
  215.     }
  216.     if ( size( $historyAttrs ) > 0 ) {
  217.         for ( $node in $historyNodes ) {
  218.             for ( $attr in $historyAttrs ) {
  219.                 setEditor -edit -addToSet -itemToAdd ( $node + "." + $attr ) 
  220.                     $setEd;
  221.             }
  222.         }
  223.         $itemsAdded = true;
  224.     }
  225.  
  226.     if ( !$itemsAdded ) {
  227.         // Nothing was selected in the channel box
  228.         //
  229.         warning( "No attributes are selected in the channel box." );
  230.     }
  231.  
  232. }
  233.  
  234. global proc
  235. buildSetEdEditMenu (string $setEd, string $parentMenu)
  236. {
  237.     setParent -menu $parentMenu;
  238.  
  239.     // These should be unique enough names for the widgets for this
  240.     // instance of the set editor
  241.  
  242.     string $addItem        = ($setEd + "addItem");
  243.     string $addChannelItem = ($setEd + "addChannelBoxItem");
  244.     string $removeItem     = ($setEd + "removeItem");
  245.     string $setKeyItem     = ($setEd + "setKeyItem");
  246.     string $selectAttrItem = ($setEd + "selectAttrItem");
  247.  
  248.     // Check to see if we have to build the menu items
  249.  
  250.     if (`menu -query -numberOfItems $parentMenu` == 0)
  251.     {
  252.         menuItem -label "Add Items" 
  253.             -command ( "setEditor -edit -addToSet " + $setEd )
  254.             $addItem;
  255.         menuItem -label "Add Items from Channel Box" 
  256.             -command ( "setEditorAddChannelBoxToSet( \"" + $setEd + "\" )" )
  257.             $addChannelItem;
  258.         menuItem -label "Remove Items"
  259.             -command ("setEditor -edit -removeFromSet " + $setEd)
  260.             $removeItem;
  261.  
  262.         menuItem -l "Create Set"
  263.             -annotation "Create Set: Make a set containing the selected object(s)"            
  264.             -c "performCreateSet false";
  265.         menuItem -optionBox true 
  266.             -l "Create Set Option Box"
  267.             -c "performCreateSet true";
  268.         
  269.         menuItem -l "Create Partition"
  270.             -annotation "Create Partition: Make a partition containing the selected set(s)"            
  271.             -c "performCreatePartition false";
  272.         menuItem -optionBox true 
  273.             -l "Create Partition Option Box"
  274.             -c "performCreatePartition true";
  275.  
  276.         menuItem -divider true;
  277.  
  278.         menuItem -label "Key Selected Weight(s)"
  279.             -command ("setEditor -edit -awc setKeyframe "+$setEd)
  280.             $setKeyItem;
  281.  
  282.         menuItem -label "Select Weight Attribute(s)"
  283.             -command ("setEditor -edit -awc select "+$setEd)
  284.             $selectAttrItem;
  285.  
  286.     }
  287.  
  288.     // Disable add/remove entries if we are not in editing mode
  289.  
  290.     string $operatingMode = `setEditor -query -mode $setEd`;
  291.     menuItem -edit -enable ($operatingMode == "editing") $addItem;
  292.     menuItem -edit -enable ($operatingMode == "editing") $removeItem;
  293. }
  294.  
  295. global proc
  296. updateSetEdFiltersMenu (string $setEd, string $parentMenu)
  297. {
  298.     setParent -menu $parentMenu;
  299.  
  300.     // These should be unique enough names for the widgets for this
  301.     // instance of the set editor
  302.  
  303.     string $showNormalSetsItem          = ($setEd + "showNormalSetsItem");
  304.     string $showRenderSetsItem          = ($setEd + "showRenderSetsItem");
  305.     string $showDeformerSetsItem        = ($setEd + "showDeformerSetsItem");
  306. //    string $showCustomFiltersMenu       = ($setEd + "showCustomFiltersMenu");
  307. //    string $showBoneLatticeSetsItem     = ($setEd + "showBoneLatticeSetsItem");
  308.     string $showBlendShapeSetsItem      = ($setEd + "showBlendShapeSetsItem");
  309.     string $showClusterSetsItem         = ($setEd + "showClusterSetsItem");
  310.     string $showJointClusterSetsItem    = ($setEd + "showJointClusterSetsItem");
  311. //    string $showJointLatticeSetsItem    = ($setEd + "showJointLatticeSetsItem");
  312.     string $showLatticeSetsItem         = ($setEd + "showLatticeSetsItem");
  313.     string $showLatticeDualBaseSetsItem = ($setEd + "showLatticeDualBaseSetsItem");
  314.     string $showSculptSetsItem          = ($setEd + "showSculptSetsItem");
  315.     string $showWireSetsItem            = ($setEd + "showWireSetsItem");
  316.  
  317.     menuItem -edit
  318.         -checkBox `setEditor -query -showNormalSets $setEd`
  319.         $showNormalSetsItem;
  320.     menuItem -edit
  321.         -checkBox `setEditor -query -showRenderSets $setEd`
  322.         $showRenderSetsItem;
  323.     menuItem -edit
  324.         -checkBox `setEditor -query -showDeformerSets $setEd`
  325.         $showDeformerSetsItem;
  326. //    menuItem -edit
  327. //        -checkBox `setEditor -query -showBoneLatticeSets $setEd`
  328. //        $showBoneLatticeSetsItem;
  329.     menuItem -edit
  330.         -checkBox `setEditor -query -showBlendShapeSets $setEd`
  331.         $showBlendShapeSetsItem;
  332.     menuItem -edit
  333.         -checkBox `setEditor -query -showClusterSets $setEd`
  334.         $showClusterSetsItem;
  335.     menuItem -edit
  336.         -checkBox `setEditor -query -showJointClusterSets $setEd`
  337.         $showJointClusterSetsItem;
  338. //    menuItem -edit
  339. //        -checkBox `setEditor -query -showJointLatticeSets $setEd`
  340. //        $showJointLatticeSetsItem;
  341.     menuItem -edit
  342.         -checkBox `setEditor -query -showLatticeSets $setEd`
  343.         $showLatticeSetsItem;
  344.     menuItem -edit
  345.         -checkBox `setEditor -query -showLatticeDualBaseSets $setEd`
  346.         $showLatticeDualBaseSetsItem;
  347.     menuItem -edit
  348.         -checkBox `setEditor -query -showSculptSets $setEd`
  349.         $showSculptSetsItem;
  350.     menuItem -edit
  351.         -checkBox `setEditor -query -showWireSets $setEd`
  352.         $showWireSetsItem;
  353.  
  354.     int $enableDefs = !`setEditor -query -showDeformerSets $setEd`;
  355.  
  356.     int $inSetsMode = true;
  357.     if (!`setEditor -query -editSets $setEd`)
  358.     {
  359.         $inSetsMode = false;
  360.         $enableDefs = false;
  361.     }
  362.  
  363.     menuItem -edit -enable $inSetsMode $showNormalSetsItem;
  364.     menuItem -edit -enable $inSetsMode $showRenderSetsItem;
  365.     menuItem -edit -enable $inSetsMode $showDeformerSetsItem;
  366.  
  367. //    menuItem -edit -enable $enableDefs $showBoneLatticeSetsItem;
  368.     menuItem -edit -enable $enableDefs $showBlendShapeSetsItem;
  369.     menuItem -edit -enable $enableDefs $showClusterSetsItem;
  370.     menuItem -edit -enable $enableDefs $showJointClusterSetsItem;
  371. //    menuItem -edit -enable $enableDefs $showJointLatticeSetsItem;
  372.     menuItem -edit -enable $enableDefs $showLatticeSetsItem;
  373.     menuItem -edit -enable $enableDefs $showLatticeDualBaseSetsItem;
  374.     menuItem -edit -enable $enableDefs $showSculptSetsItem;
  375.     menuItem -edit -enable $enableDefs $showWireSetsItem;
  376. }
  377.  
  378. global proc
  379. buildSetEdFiltersMenu (string $setEd, string $parentMenu)
  380. {
  381.     setParent -menu $parentMenu;
  382.  
  383.     // These should be unique enough names for the widgets for this
  384.     // instance of the set editor
  385.  
  386.     string $showNormalSetsItem          = ($setEd + "showNormalSetsItem");
  387.     string $showRenderSetsItem          = ($setEd + "showRenderSetsItem");
  388.     string $showDeformerSetsItem        = ($setEd + "showDeformerSetsItem");
  389.     string $showCustomFiltersMenu       = ($setEd + "showCustomFiltersMenu");
  390. //    string $showBoneLatticeSetsItem     = ($setEd + "showBoneLatticeSetsItem");
  391.     string $showBlendShapeSetsItem      = ($setEd + "showBlendShapeSetsItem");
  392.     string $showClusterSetsItem         = ($setEd + "showClusterSetsItem");
  393.     string $showJointClusterSetsItem    = ($setEd + "showJointClusterSetsItem");
  394. //    string $showJointLatticeSetsItem    = ($setEd + "showJointLatticeSetsItem");
  395.     string $showLatticeSetsItem         = ($setEd + "showLatticeSetsItem");
  396.     string $showLatticeDualBaseSetsItem = ($setEd + "showLatticeDualBaseSetsItem");
  397.     string $showSculptSetsItem          = ($setEd + "showSculptSetsItem");
  398.     string $showWireSetsItem            = ($setEd + "showWireSetsItem");
  399.  
  400.     // Check to see if we have to build the menu items
  401.  
  402.     if (`menu -query -numberOfItems $parentMenu` == 0)
  403.     {
  404.         menuItem -label "All Regular Sets"
  405.             -checkBox 0
  406.             -command ("setEditor -edit -showNormalSets #1 " + $setEd)
  407.             $showNormalSetsItem;
  408.         menuItem -label "All Render Sets"
  409.             -checkBox 0
  410.             -command ("setEditor -edit -showRenderSets #1 " + $setEd)
  411.             $showRenderSetsItem;
  412.         menuItem -label "All Deformer Sets"
  413.             -checkBox 0
  414.             -command ("setEditor -edit -showDeformerSets #1 " + $setEd + " ; updateSetEdFiltersMenu " + $setEd + " " + $parentMenu)
  415.             $showDeformerSetsItem;
  416.  
  417.         menuItem -label "Item Filters" -subMenu true $showCustomFiltersMenu;
  418.         menuItem -edit
  419.             -postMenuCommand ("buildSetEdCustomFiltersMenu " + $setEd + " " + $showCustomFiltersMenu)
  420.             $showCustomFiltersMenu;
  421.         setParent -menu ..;
  422.  
  423.         menuItem -divider true;
  424.  
  425. // This is the set containing the actual points in the bone lattice
  426. // so it is not very interesting.
  427. //
  428. //        menuItem -label "Bone Lattice Sets"
  429. //            -checkBox 0
  430. //            -command ("setEditor -edit -showBoneLatticeSets #1 " + $setEd)
  431. //            $showBoneLatticeSetsItem;
  432.         menuItem -label "Blend Shape Sets"
  433.             -checkBox 0
  434.             -command ("setEditor -edit -showBlendShapeSets #1 " + $setEd)
  435.             $showBlendShapeSetsItem;
  436.         menuItem -label "Cluster Sets"
  437.             -checkBox 0
  438.             -command ("setEditor -edit -showClusterSets #1 " + $setEd)
  439.             $showClusterSetsItem;
  440.         menuItem -label "Joint Cluster Sets"
  441.             -checkBox 0
  442.             -command ("setEditor -edit -showJointClusterSets #1 " + $setEd)
  443.             $showJointClusterSetsItem;
  444. // This is the set containing the actual points in the joint lattice
  445. // so it is not very interesting.
  446. //
  447. //        menuItem -label "Joint Lattice Flexor Sets"
  448. //            -checkBox 0
  449. //            -command ("setEditor -edit -showJointLatticeSets #1 " + $setEd)
  450. //            $showJointLatticeSetsItem;
  451.         menuItem -label "Joint Lattice Sets"
  452.             -checkBox 0
  453.             -command ("setEditor -edit -showLatticeDualBaseSets #1 " + $setEd)
  454.             $showLatticeDualBaseSetsItem;
  455.         menuItem -label "Lattice Sets"
  456.             -checkBox 0
  457.             -command ("setEditor -edit -showLatticeSets #1 " + $setEd)
  458.             $showLatticeSetsItem;
  459.         menuItem -label "Sculpt Sets"
  460.             -checkBox 0
  461.             -command ("setEditor -edit -showSculptSets #1 " + $setEd)
  462.             $showSculptSetsItem;
  463.         menuItem -label "Wire Sets"
  464.             -checkBox 0
  465.             -command ("setEditor -edit -showWireSets #1 " + $setEd)
  466.             $showWireSetsItem;
  467.     }
  468.  
  469.     updateSetEdFiltersMenu($setEd, $parentMenu);
  470. }
  471.  
  472.  
  473. global proc
  474. buildSetEdListMenu (string $setEd, string $parentMenu)
  475. {
  476.     setParent -menu $parentMenu;
  477.  
  478.     // These should be unique enough names for the widgets for this
  479.     // instance of the set editor. The filters item needs a wee bit
  480.     // extra uniqueness since it gets used in the update filters callback.
  481.  
  482.     string $scrollItem     = ($setEd + "scrollItem");
  483.     string $expandItem     = ($setEd + "expandItem");
  484.     string $collapseItem   = ($setEd + "collapseItem");
  485.     string $setsItem       = ($setEd + "setItem");
  486.     string $partitionsItem = ($setEd + "partitionItem");
  487.     string $updateItem     = ($setEd + "updateItem");
  488.     string $addToListItem  = ($setEd + "addToListItem");
  489.     string $allItem        = ($setEd + "allItem");
  490.     string $filtersItem    = ($setEd + $parentMenu + "filtersItem");
  491.     
  492.     // Check to see if we have to build the menu items
  493.  
  494.     if (`menu -query -numberOfItems $parentMenu` == 0)
  495.     {
  496.         menuItem -label "Scroll Frames to Selection" 
  497.             -command ("setEditor -edit -scrollFrames " + $setEd)
  498.             $scrollItem;
  499.  
  500.         menuItem -label "Expand All Frames"
  501.             -command ("setEditor -edit -expandFrames " + $setEd)
  502.             $expandItem;
  503.  
  504.         menuItem -label "Collapse All Frames"
  505.             -command ("setEditor -edit -collapseFrames " + $setEd)
  506.             $collapseItem;
  507.  
  508.         menuItem -divider true;
  509.  
  510.         radioMenuItemCollection;
  511.             menuItem -label "Sets"
  512.                 -radioButton true
  513.                 -command ("setEditor -edit -editSets " + $setEd) $setsItem;
  514.             menuItem -label "Partitions"
  515.                 -radioButton false
  516.                 -command ("setEditor -edit -editPartitions " + $setEd) $partitionsItem;
  517.         setParent -menu $parentMenu;
  518.  
  519.         menuItem -divider true;
  520.  
  521.         menuItem -label "Update Now" 
  522.             -command ("setEditor -edit -reload " + $setEd)
  523.             $updateItem;
  524.         menuItem -label "Add Selected to List" 
  525.             -command ("setEditor -edit -addToList " + $setEd)
  526.             $addToListItem;
  527.         menuItem -label "All Sets"
  528.             -command ("setEditor -edit -allSets " + $setEd)
  529.             $allItem;
  530.  
  531.         menuItem -divider true;
  532.  
  533.         menuItem -label "Filters" -subMenu true -tearOff true $filtersItem;
  534.     }
  535.  
  536.     // Update state and enable/disable status
  537.  
  538.     buildSetEdFiltersMenu($setEd, $filtersItem);
  539.     string $operatingMode = `setEditor -query -mode $setEd`;
  540.     if ($operatingMode == "selectExpand" || $operatingMode == "selectNoExpand")
  541.     {
  542.         menuItem -edit -enable false $scrollItem;
  543.         menuItem -edit -enable false $expandItem;
  544.         menuItem -edit -enable false $collapseItem;
  545.     }
  546.     else
  547.     {
  548.         int $enableScroll = `setEditor -query -groupComponents $setEd`;
  549.         menuItem -edit -enable $enableScroll $scrollItem;
  550.         menuItem -edit -enable true $expandItem;
  551.         menuItem -edit -enable true $collapseItem;
  552.     }
  553.     if (`setEditor -query -editSets $setEd`)
  554.     {
  555.         menuItem -edit -radioButton true $setsItem;
  556.         menuItem -edit -enable true $updateItem;
  557.         menuItem -edit -enable true $addToListItem;
  558.         menuItem -edit -enable true $allItem;
  559.     }
  560.     else
  561.     {
  562.         menuItem -edit -radioButton true $partitionsItem;
  563.         menuItem -edit -enable false $updateItem;
  564.         menuItem -edit -enable false $addToListItem;
  565.         menuItem -edit -enable false $allItem;
  566.     }
  567.     menuItem -edit -enable true $filtersItem;
  568. }
  569.  
  570. global proc
  571. buildSetEdBookmarksMenu (string $setEd, string $parentMenu)
  572. {
  573.     setParent -menu $parentMenu;
  574.  
  575.     menu -e -deleteAllItems $parentMenu;
  576.  
  577.     menuItem -label "Add Bookmark" -command ("setEdBookmarkAddCallback " + $setEd + " later");
  578.     menuItem -optionBox true -l "Add Bookmark Option Box"
  579.         -command ("setEdBookmarkAddCallback " + $setEd + " first");
  580.     menuItem -label "Bookmark Editor..." -command ("setEdBookmarkEditor " + $setEd);
  581.     menuItem -divider true;
  582.     menuItem -divider true;
  583.     
  584.     // Create a menu item for each bookmark
  585.  
  586.     string $bookmarks[] = `setEditor -query -listBookmarks $setEd`;
  587.     string $bookmark;
  588.  
  589.     for ($bookmark in $bookmarks)
  590.     {
  591.         menuItem -l $bookmark
  592.             -command ("setEditor -edit -useBookmark " + $bookmark + " " + $setEd);
  593.         menuItem -optionBox true -l ($bookmark + " Option Box")
  594.             -command ("setEdBookmarkRenameMenuCallback " + $setEd + " " + $bookmark);
  595.     }
  596. }
  597.  
  598. global proc
  599. buildSetEdCustomFiltersMenu (string $setEd, string $parentMenu)
  600. {
  601.     setParent -menu $parentMenu;
  602.  
  603.     // Get rid of previous menu contents
  604.     menu -e -deleteAllItems $parentMenu;
  605.  
  606.     // Get list of all existing custom filters
  607.     string $filterNames[] = `lsUI -filters`;
  608.  
  609.     // Determine current filter being used by the set editor
  610.     string $currFilter = `setEditor -query -filter $setEd`;
  611.  
  612.     // Create an menu entry for each existing filter 
  613.  
  614.      string $noFilterItem = `menuItem -rb 1 -label "No Filter"`;
  615.     menuItem -e -command ("setEditor -edit -filter 0 " + $setEd) $noFilterItem;
  616.  
  617.     for ($i = 0; $i < size($filterNames); $i++)
  618.     {
  619.         string $fname = $filterNames[$i];
  620.  
  621.         menuItem -rb 0 -label `interToUI $fname`
  622.             -c ("setEditor -edit -filter " + $fname + " " + $setEd)
  623.             ($fname + "Item");
  624.         if ($fname == $currFilter)
  625.         {
  626.             menuItem -e -rb 1 ($fname + "Item");
  627.             menuItem -e -rb 0 $noFilterItem;
  628.         } 
  629.     }
  630. }
  631.  
  632. global proc
  633. buildSetEdOptionsMenu (string $setEd, string $parentMenu)
  634. {
  635.     setParent -menu $parentMenu;
  636.  
  637.     // These should be unique enough names for the widgets for this
  638.     // instance of the set editor
  639.  
  640.     string $autoUpdateItem     = ($setEd + "autoUpdateItem");
  641.     string $autoExpandItem     = ($setEd + "autoExpandItem");
  642.     string $autoScrollItem     = ($setEd + "autoScrollItem");
  643.     string $listByObjectItem   = ($setEd + "listByObject");
  644.     string $listLengthItem     = ($setEd + "listLengthItem");
  645.  
  646.     // Check to see if we have to build the menu items
  647.  
  648.     if (`menu -query -numberOfItems $parentMenu` == 0)
  649.     {
  650.         menuItem -label "Auto Update"
  651.             -checkBox 0
  652.             -command ("setEditor -edit -autoUpdate #1 " + $setEd + " ; updateMenuGreyStates " + $setEd)
  653.             $autoUpdateItem;
  654.         menuItem -label "Auto Expand Frames"
  655.             -checkBox 0
  656.             -command ("setEditor -edit -autoExpand #1 " + $setEd)
  657.             $autoExpandItem;
  658.         if (!`about -nt`) {
  659.             menuItem -label "Auto Scroll to Selection"
  660.                 -checkBox 0
  661.                 -command ("setEditor -edit -autoScroll #1 " + $setEd)
  662.                 $autoScrollItem;
  663.         }
  664.         menuItem -label "List by Object"
  665.             -checkBox 0
  666.             -command ("setEditor -edit -groupComponents #1 " + $setEd)
  667.             $listByObjectItem;
  668.         if (!`about -nt`) {
  669.             menuItem -label "Object List Length ..."
  670.                 -command ("performListLength " + $setEd)
  671.                 $listLengthItem;
  672.         }
  673.     }
  674.  
  675.     // Update the checkbox state for the menu items
  676.  
  677.     menuItem -edit
  678.         -checkBox `setEditor -query -autoUpdate $setEd`
  679.         $autoUpdateItem;
  680.     menuItem -edit
  681.         -checkBox `setEditor -query -autoExpand $setEd`
  682.         $autoExpandItem;
  683.     if (!`about -nt`) {
  684.         menuItem -edit
  685.             -checkBox `setEditor -query -autoScroll $setEd`
  686.             $autoScrollItem;
  687.     }
  688.     menuItem -edit
  689.         -checkBox `setEditor -query -groupComponents $setEd`
  690.         $listByObjectItem;
  691.  
  692.     // Update the enable/disable state for the menu items
  693.  
  694.     string $operatingMode = `setEditor -query -mode $setEd`;
  695.     if ($operatingMode == "selectExpand" || $operatingMode == "selectNoExpand"
  696.         || `setEditor -query -autoUpdate $setEd`)
  697.     {
  698.         menuItem -edit -enable false $autoExpandItem;
  699.         menuItem -edit -enable false $listByObjectItem;
  700.         if (!`about -nt`) {
  701.             menuItem -edit -enable false $autoScrollItem;
  702.             menuItem -edit -enable false $listLengthItem;
  703.         }
  704.     }
  705.     else
  706.     {
  707.         menuItem -edit -enable true $autoExpandItem;
  708.         menuItem -edit -enable true $listByObjectItem;
  709.         if (!`about -nt` && `setEditor -query -groupComponents $setEd`)
  710.         {
  711.             if (!`about -nt`) {
  712.                 menuItem -edit -enable true $autoScrollItem;
  713.                 menuItem -edit -enable true $listLengthItem;
  714.             }
  715.         }
  716.         else
  717.         {
  718.             if (!`about -nt`) {
  719.                 menuItem -edit -enable false $autoScrollItem;
  720.                 menuItem -edit -enable false $listLengthItem;
  721.             }
  722.         }
  723.     }
  724. }
  725.  
  726. global proc
  727. performListLength (string $setEd)
  728. {
  729.     window -title "Mini Scroll Bar Length" -width 240 setTempWindow;
  730.     columnLayout -adj true;
  731.     intField -min 1 -max 100 -value 1 intItem;
  732.     intField -edit -value (`setEditor -query -componentListLength $setEd`) intItem;
  733.     intField -edit -cc ("setEditor -edit -componentListLength #1 " + $setEd) intItem;;
  734.     showWindow setTempWindow;
  735. }
  736.  
  737. global proc
  738. //showSetEditorMenu (int $show, string $frameLayout)
  739. showSetEditorMenu (int $show, string $menuBarLayout)
  740. {
  741.     if ($show) {
  742. //        frameLayout -edit -collapse false $frameLayout;
  743.         menuBarLayout -e -h 25 $menuBarLayout;
  744.     }
  745.     else {
  746. //        frameLayout -edit -collapse true $frameLayout;
  747.         menuBarLayout -e -h 1 $menuBarLayout;
  748.     }
  749.     optionVar -intValue showSetEditorMenu $show;
  750. }
  751.  
  752. global proc SetEditorPopupMenu(string $setEd)
  753. //
  754. //  Description:
  755. //      This script creates popup menu items for the set editor.
  756. //
  757. {
  758.     // Define a unique name for the popup menu for this
  759.     // instance of the set editor
  760.     string $menuPopup = ($setEd + "menuPopup");
  761.  
  762.     popupMenu -ctrlModifier false
  763.         -button 3 -aob false -parent $setEd
  764.         $menuPopup;
  765.  
  766.         // These should be unique enough names for the widgets for this
  767.         // instance of the set editor
  768.  
  769.         string $modePopupMenu = ($setEd + "modePopupMenu");
  770.         string $editPopupMenu = ($setEd + "editPopupMenu");
  771.         string $listPopupMenu = ($setEd + "listPopupMenu");
  772.         string $bookmarksPopupMenu = ($setEd + "bookmarksPopupMenu");
  773.         string $optionsPopupMenu = ($setEd + "optionsPopupMenu");
  774.  
  775.         menuItem -label "Mode" -tearOff true -subMenu true $modePopupMenu;
  776.         menuItem -edit -postMenuCommand ("buildSetEdModeMenu " + $setEd + " " + $modePopupMenu) $modePopupMenu;
  777.         setParent -menu ..;
  778.  
  779.         menuItem -label "Edit" -tearOff true -subMenu true -aob true $editPopupMenu;
  780.         menuItem -edit -postMenuCommand ("buildSetEdEditMenu " + $setEd + " " + $editPopupMenu) $editPopupMenu;
  781.         setParent -menu ..;
  782.  
  783.         menuItem -label "List" -tearOff true -subMenu true $listPopupMenu;
  784.         menuItem -edit -postMenuCommand ("buildSetEdListMenu " + $setEd + " " + $listPopupMenu) $listPopupMenu;
  785.         setParent -menu ..;
  786.  
  787.         // Since the bookmark menu is dynamic allowing it to be torn off
  788.         // causes crashes
  789.         menuItem -label "Bookmarks" -tearOff false -subMenu true -aob true $bookmarksPopupMenu;
  790.         menuItem -edit -postMenuCommand ("buildSetEdBookmarksMenu " + $setEd + " " + $bookmarksPopupMenu) $bookmarksPopupMenu;
  791.         setParent -menu ..;
  792.  
  793.         menuItem -label "Options" -tearOff true -subMenu true $optionsPopupMenu;
  794.         menuItem -edit -postMenuCommand ("buildSetEdOptionsMenu " + $setEd + " " + $optionsPopupMenu) $optionsPopupMenu;
  795.         setParent -menu ..;
  796.  
  797.     setParent -menu ..;
  798. }
  799.  
  800. // *********************************************
  801. // End of menu creation procedures.
  802. // *********************************************
  803.  
  804.  
  805. global proc
  806. createSetEditor (string $whichPanel)
  807. //
  808. //  Description:
  809. //        Define the editors that are used in this panel.  No
  810. //        controls (widgets) are created at this point.
  811. //
  812. {
  813.     // Create a unique name for the editor based on panel name
  814.  
  815.     string $setEd = ($whichPanel + "SetEd");
  816.     setEditor -unParent $setEd;
  817. }
  818.  
  819. global proc
  820. addSetEditor (string $whichPanel)
  821. //
  822. //  Description:
  823. //        Add the panel to a layout.
  824. //        Parent the editors to that layout and create any other
  825. //        controls (widgets) required.
  826. //
  827. {
  828.     string $setEd = ($whichPanel + "SetEd");
  829.  
  830.     waitCursor -state on;
  831.  
  832.     // Define the standard set editing panel
  833.  
  834.     string $menuBarLayoutName = `scriptedPanel -q -control $whichPanel`;
  835.     string $formLayoutName = `formLayout`;
  836.         
  837.     if (`optionVar -exists showSetEditorMenu`) {
  838.         showSetEditorMenu (`optionVar -query showSetEditorMenu`) $menuBarLayoutName;
  839.     }
  840.  
  841.     // Attach the menus to the menu form
  842.  
  843. //    setParent -menu $menuBarLayoutName;
  844.     setParent $menuBarLayoutName;
  845.  
  846.         // These should be unique enough names for the widgets for this
  847.         // instance of the set editor
  848.  
  849.         string $modeMenu = ($setEd + "modeMenu");
  850.         string $editMenu = ($setEd + "editMenu");
  851.         string $listMenu = ($setEd + "listMenu");
  852.         string $bookmarksMenu = ($setEd + "bookmarksMenu");
  853.         string $optionsMenu = ($setEd + "optionsMenu");
  854.  
  855.         menu -label "Mode" 
  856.             -tearOff true 
  857.             -familyImage "menuIconMode.xpm"
  858.             $modeMenu;
  859.         menu -edit -postMenuCommand ("buildSetEdModeMenu " + $setEd + " " + $modeMenu) $modeMenu;
  860.         setParent -menu ..;
  861.  
  862.         menu -label "Edit" 
  863.             -tearOff true 
  864.             -aob true 
  865.             -familyImage "menuIconEdit.xpm"
  866.             $editMenu;
  867.         menu -edit -postMenuCommand ("buildSetEdEditMenu " + $setEd + " " + $editMenu) $editMenu;
  868.         setParent -menu ..;
  869.  
  870.         menu -label "List" 
  871.             -tearOff true 
  872.             -familyImage "menuIconList.xpm"
  873.             $listMenu;
  874.         menu -edit -postMenuCommand ("buildSetEdListMenu " + $setEd + " " + $listMenu) $listMenu;
  875.         setParent -menu ..;
  876.  
  877.         // Since the bookmark menu is dynamic allowing it to be torn off
  878.         // causes crashes
  879.         menu -label "Bookmarks" 
  880.             -tearOff false 
  881.             -aob true 
  882.             -familyImage "menuIconBookmarks.xpm"
  883.             $bookmarksMenu;
  884.         menu -edit -postMenuCommand ("buildSetEdBookmarksMenu " + $setEd + " " + $bookmarksMenu) $bookmarksMenu;
  885.         setParent -menu ..;
  886.  
  887.         menu -label "Options" 
  888.             -tearOff true 
  889.             -familyImage "menuIconOptions.xpm"
  890.             $optionsMenu;
  891.         menu -edit -postMenuCommand ("buildSetEdOptionsMenu " + $setEd + " " + $optionsMenu) $optionsMenu;
  892.         setParent -menu ..;
  893.  
  894.     //    Setup buttons for the toolbar
  895.  
  896.     setParent $formLayoutName;
  897.  
  898.     //    Construct unique names for the buttons
  899.     //    for this instance of the editor
  900.  
  901.     string $setEdToolBarForm    = ($setEd + "toolbarForm");
  902.     string $editModeBtn            = ($setEd + "editModeBtn");
  903.     string $selectModeBtn        = ($setEd + "selectModeBtn");
  904.     string $contentsModeBtn        = ($setEd + "contentsModeBtn");
  905.     string $paintModeBtn        = ($setEd + "paintModeBtn");
  906.     string $scrollBtn            = ($setEd + "scrollBtn");
  907.     string $expandAllBtn        = ($setEd + "expandAllBtn");
  908.     string $collapseAllBtn        = ($setEd + "collapseAllBtn");
  909.     string $addItemsBtn            = ($setEd + "addItemsBtn");
  910.     string $removeItemsBtn        = ($setEd + "removeItemsBtn");
  911.     string $listSetsBtn            = ($setEd + "listSetsBtn");
  912.     string $listPartitionsBtn    = ($setEd + "listPartitionsBtn");
  913.  
  914.     rowLayout -nc 13
  915.         -cw 1 28 -cw 2 28 -cw 3 28 -cw 4 28
  916.         -cw 5 10 -cw 6 28 -cw 7 28 -cw 8 28
  917.         -cw 9 28 -cw 10 28 -cw 11 10 -cw 12 28 -cw 13 28
  918.         -columnAttach 5 "both" 0 -columnAttach 11 "both" 0
  919.         $setEdToolBarForm;
  920.  
  921.         symbolCheckBox -image "setEdEditMode.xpm"
  922.             -height 28 -width 28
  923.             -onCommand ("setEditor -edit -mode editing " + $setEd)
  924.             -ann "Edit Mode" $editModeBtn;
  925.         symbolCheckBox -image "setEdSelectMode.xpm"
  926.             -height 28 -width 28
  927.             -onCommand ("setEditor -edit -mode selectNoExpand " + $setEd)
  928.             -ann "Select Mode" $selectModeBtn;
  929.         symbolCheckBox -image "setEdSelectNEMode.xpm"
  930.             -height 28 -width 28
  931.             -onCommand ("setEditor -edit -mode selectExpand " + $setEd)
  932.             -ann "Select Contents Mode" $contentsModeBtn;
  933.         symbolCheckBox -image "setEdPaintMode.xpm"
  934.             -height 28 -width 28
  935.             -onCommand ("setEditor -edit -mode paint " + $setEd)
  936.             -ann "Paint Percentages Mode" $paintModeBtn;
  937.  
  938.         separator -horizontal false -style "in" -height 28 setSep1;
  939.  
  940.         symbolButton -image "setEdScrollCmd.xpm"
  941.             -height 28 -width 28
  942.             -command ("setEditor -edit -scrollFrames " + $setEd)
  943.             -ann "Scroll Frames to Selection"
  944.             $scrollBtn;
  945.         symbolButton -image "setEdExpandCmd.xpm" 
  946.             -height 28 -width 28
  947.             -command ("setEditor -edit -expandFrames " + $setEd)
  948.             -ann "Expand All Frames"
  949.             $expandAllBtn;
  950.         symbolButton -image "setEdCollapseCmd.xpm" 
  951.             -height 28 -width 28
  952.             -command ("setEditor -edit -collapseFrames " + $setEd)
  953.             -ann "Collapse All Frames"
  954.             $collapseAllBtn;
  955.         symbolButton -image "setEdAddCmd.xpm" 
  956.             -height 28 -width 28
  957.             -command ("setEditor -edit -addToSet " + $setEd)
  958.             -ann "Add Items to Selected"
  959.             $addItemsBtn;
  960.         symbolButton -image "setEdRemoveCmd.xpm" 
  961.             -height 28 -width 28
  962.             -command ("setEditor -edit -removeFromSet " + $setEd)
  963.             -ann "Remove Items from Selected"
  964.             $removeItemsBtn;
  965.  
  966.         separator -horizontal false -style "in" -height 28 setSep2;
  967.  
  968.         symbolCheckBox -image "setEdListSetMode.xpm"
  969.             -height 28 -width 28
  970.             -onCommand ("setEditor -edit -editSets " + $setEd)
  971.             -ann "List Sets Mode" $listSetsBtn;
  972.         symbolCheckBox -image "setEdListPartMode.xpm"
  973.             -height 28 -width 28
  974.             -onCommand ("setEditor -edit -editPartitions " + $setEd)
  975.             -ann "List Partitions Mode" $listPartitionsBtn;
  976.     setParent ..;
  977.  
  978.     // Parent the editor to the editor layout
  979.  
  980.     setEditor -edit -parent $formLayoutName $setEd;
  981.     formLayout -edit
  982.         -attachForm $setEdToolBarForm "left" 0
  983.         -attachForm $setEdToolBarForm "right" 0
  984.         -attachForm $setEdToolBarForm "top" 0
  985.         -attachNone $setEdToolBarForm "bottom" 
  986.  
  987.         -attachForm $setEd left 0
  988.         -attachForm $setEd right 0
  989.         -attachControl $setEd top 0 $setEdToolBarForm
  990.         -attachForm $setEd bottom 0
  991.         $formLayoutName;
  992.  
  993.     // Attach popup menus to the set editor
  994.  
  995.     SetEditorPopupMenu $setEd;
  996.  
  997.     // Create a scriptJob to keep the toolbar buttons
  998.     // in sync with this instance of the setEditor.
  999.     // Parent it to this instance of the set editor so
  1000.     // the script job goes away when the editor is
  1001.     // closed.
  1002.  
  1003.     scriptJob 
  1004.         -e "setEditorChanged" 
  1005.         ("setEditorStateCallback " + $setEd)
  1006.         -p $setEd; 
  1007.  
  1008.     // Make sure the buttons start off in sync
  1009.     setEditorStateCallback $setEd;
  1010.  
  1011.     setParent -top;
  1012.     waitCursor -state off;
  1013. }
  1014.  
  1015. global proc
  1016. removeSetEditor (string $whichPanel)
  1017. //
  1018. //  Description:
  1019. //        Remove the panel from a layout.
  1020. //        Delete controls.
  1021. //
  1022. {
  1023.     string $setEd = ($whichPanel + "SetEd");
  1024.  
  1025.     if (`setEditor -exists $setEd`) {
  1026.         setEditor -edit -unParent $setEd;
  1027.     }
  1028. }
  1029.  
  1030. global proc
  1031. deleteSetEditor (string $whichPanel)
  1032. //
  1033. //  Description:
  1034. //        This proc will delete the contents of the panel, but not
  1035. //        the panel itself.
  1036. //
  1037. //  Note:
  1038. //        We only need to delete editors here.  Other UI will be taken care of
  1039. //        by the remove proc.
  1040. //
  1041. {
  1042.     string $setEd = ($whichPanel + "SetEd");
  1043.  
  1044.     if (`setEditor -exists $setEd`) {
  1045.         deleteUI -editor $setEd;
  1046.     }
  1047. }
  1048.  
  1049. global proc string
  1050. saveStateSetEditor (string $whichPanel)
  1051. //
  1052. //  Description:
  1053. //        This proc returns a string that when executed will restore the
  1054. //        current state of the panel elements.
  1055. //
  1056. {
  1057.     string $indent = "\n\t\t\t";
  1058.     string $setEd = ($whichPanel + "SetEd");
  1059.  
  1060.     return (
  1061.             $indent + "$editorName = ($panelName+\"SetEd\");\n" +
  1062.             `setEditor -query -stateString $setEd`
  1063.             );
  1064. }
  1065.  
  1066. global proc
  1067. updateMenuGreyStates (string $setEd)
  1068. {
  1069.     // Always keep the options menu enabled or the user won't
  1070.     // be able to turn auto update mode off!
  1071.  
  1072.     // Use the unique enough names to update the menubar and popup menu
  1073.     // enabled state
  1074.  
  1075.     string $modeMenu = ($setEd + "modeMenu");
  1076.     string $editMenu = ($setEd + "editMenu");
  1077.     string $listMenu = ($setEd + "listMenu");
  1078.     string $bookmarksMenu = ($setEd + "bookmarksMenu");
  1079.     //string $optionsMenu = ($setEd + "optionsMenu");
  1080.  
  1081.     string $modePopupMenu = ($setEd + "modePopupMenu");
  1082.     string $editPopupMenu = ($setEd + "editPopupMenu");
  1083.     string $listPopupMenu = ($setEd + "listPopupMenu");
  1084.     string $bookmarksPopupMenu = ($setEd + "bookmarksPopupMenu");
  1085.     //string $optionsPopupMenu = ($setEd + "optionsPopupMenu");
  1086.  
  1087.     int $enableMenus = !`setEditor -query -autoUpdate $setEd`;
  1088.  
  1089.     menu -edit -enable $enableMenus $modeMenu;
  1090.     menu -edit -enable $enableMenus $editMenu;
  1091.     menu -edit -enable $enableMenus $listMenu;
  1092.     menu -edit -enable $enableMenus $bookmarksMenu;
  1093.     menuItem -edit -enable $enableMenus $modePopupMenu;
  1094.     menuItem -edit -enable $enableMenus $editPopupMenu;
  1095.     menuItem -edit -enable $enableMenus $listPopupMenu;
  1096.     menuItem -edit -enable $enableMenus $bookmarksPopupMenu;
  1097. }
  1098.